﻿/// <reference path="../../Content/js/angular.js" />
app.service('alertboxservice', ['$http', function ($http) {
    this.ShowMsg = function (responce, modelname) {
        if (responce == 'ISUS') {
            $('#' + modelname).modal('hide');
            messagebox.success(modelname + "added successfully");
        }
        else if (responce == 'PLEASEIMAGE') {
            messagebox.warning("Please select image");
        }
        else if (responce == 'MOTHEREXITS') {
            messagebox.warning("Mother already Exists in this family");
        }
        else if (responce == 'FATHEREXITS') {
            messagebox.warning("Father already Exists in this family");
        }
        else if (responce == 'REXISTS') {
            messagebox.warning("Relationship already Exists");
        }
        else if (responce == 'EEXISTS') {
            messagebox.warning("Details already exists");
        }
        else if (responce == 'EMAILNOTEXITS') {
            messagebox.warning("Email not exits..So you cannot assign this member");
        }
        else if (responce == 'SME') {
            messagebox.error("Sorry, Something went worng please try after sometimes");
        }
        else if (responce == 'EIX') {
            messagebox.warning("Details already exists in your system");
        }
        else if (responce == 'NAMEEXIST') {
            messagebox.warning("Name already exists in your system");
        }
        else if (responce == 'EMAILEXIST') {
            messagebox.warning("Email already exists in your system");
        }
        else if (responce == 'FAMILYNAMEEXISTS') {
            messagebox.warning("Family already exists in your system");
        }
        else if (responce == 'USUS') {
            $('#' + modelname).modal('hide');
            messagebox.success(modelname + " updated successfully");
        }
        else if (responce == 'WRONGPASSWORE') {
            messagebox.warning("Your old password is not correct");
        }
        else if (responce == 'LSUS') {
            $('#' + modelname).modal('hide');
            messagebox.success(modelname + " updated successfully");
            swal({
                title: "Are you sure want to logout System?",
                text: "Your settings is updated successfully.. Settings will be affected once you logout and loged into your system",
                type: "warning",
                showCancelButton: true,
                cancelButtonClass: 'btn-outline btn-black mr-10',
                cancelButtonText: 'Cancel',
                confirmButtonClass: "btn-danger",
                confirmButtonText: "Yes! Logout",
                closeOnConfirm: false
            }, function (status) {
                if (status) {
                    window.location = "../../";

                }
                else {

                }
            });

        }
        else if (responce == 'PCSUS') {
            messagebox.success("Password updated successfully");
            swal({
                title: "Password Changed successfully",
                text: "Do you want to logout your system in order to user your new password?",
                type: "warning",
                showCancelButton: true,
                cancelButtonClass: 'btn-outline btn-black mr-10',
                cancelButtonText: 'Cancel',
                confirmButtonClass: "btn-danger",
                confirmButtonText: "Yes! Logout",
                closeOnConfirm: false
            }, function (status) {
                if (status) {
                    window.location = "../../";
                }
                else {
                }
            });
        }
        else if (responce == 'LSUS') {
            messagebox.success(modelname + " updated successfully");
            swal({
                title: modelname + " Updated successfully",
                text: "Do you want to logout your system in order to user your new password?",
                type: "warning",
                showCancelButton: true,
                cancelButtonClass: 'btn-outline btn-black mr-10',
                cancelButtonText: 'Cancel',
                confirmButtonClass: "btn-danger",
                confirmButtonText: "Yes! Logout",
                closeOnConfirm: false
            }, function (status) {
                if (status) {
                    window.location = "../../";
                }
                else {
                }
            });
        }
        else {
            messagebox.warning(responce);
        }
    };
}]);